<%@ page language="java" pageEncoding="utf-8"%>
<%
String baseUrl = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";
%>
<%
//收到了一个前端的发表留言的请求
if(request.getParameter("action")!=null && request.getParameter("action").equals("pub_comment")){
	out.print(request.getParameter("nickname")+","+request.getParameter("content"));return;
}
%>
<!DOCTYPE html>
<html>
<base href="<%=baseUrl%>"/>
<head>
	<meta charset="utf-8">
	<link rel="stylesheet" href="static_front/css/bootstrap.min.css">
	<title>发表留言</title>
</head>



<div class="container" style="margin-top: 50px">
	<div class="row center" style="margin-bottom: 50px">
		<div class="col-md-12 text-center"><h1>发表留言</h1></div>
	</div>
	<div class="row">
		<div class="col-md-3"></div>
		<div class="col-md-6">
			<form id="form1">
				<div class="form-group row">
					<label class="col-md-2">昵称</label>
					<div class="col-md-8">		
						<input type="text" name="nickname" class="form-control">
					</div>
				</div>
				<div class="form-group row">
					<label class="col-md-2">邮箱</label>
					<div class="col-md-8">		
						<input type="text" name="email" class="form-control">
					</div>
				</div>
				<div class="form-group row">
					<label class="col-md-2">内容</label>
					<div class="col-md-10">		
						<textarea name="content" class="form-control" rows="5" cols="50"></textarea>
					</div>
				</div>
				<div class="form-group row">
					<label class="col-md-2"></label>
					<div class="col-md-10">
						<input type="hidden" name="action" value="pub_comment"/>
						<input type="button" value="提交留言" name="submit" class="btn btn-danger">
					</div>
				</div>
			</form>
		</div>
		<div class="col-md-3"></div>
	</div>

</div>

<script type="text/javascript" src="static_front/js/jquery.min.js"></script>
<script type="text/javascript" src="static_front/js/bootstrap.min.js"></script>
<script type="text/javascript">
	$(function(){
		$('input[name=submit]').click(function(){
			var data = $("#form1").serialize();//序列化整个表单为字符串，格式 username=tom&email=1@qq.com&content=aaa

			$.ajax({
			   type: "POST",
			   url: "pub_comment.jsp",
			   data: data,
			   success: function(msg){
			     alert( "服务器端返回的数据: " + msg );
			   }
			});
		})
	})
</script>

